/**
 * 模态框
 */
module.exports = function ($scope, $state, $stateParams,$resource,$modal) {
	/* 分页
     * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.currentPage = 1;      //当前页码
    $scope.itemsPerPage = 10         //每页显示几条
	$scope.obj={};
	$scope.d={};


	$scope.pageChanged = function () {
       var para = {
            pageNo:$scope.currentPage,
            pageSize:$scope.itemsPerPage,

            
        };
        		// console.log(para);

        $resource('', {}, {}).
			save(para, function(res){
				// console.log('购买须知');
                 
                if(res.errcode === 0 || res.errcode === 10003){
					$scope.a=res.data.results;
					console.log($scope.a);
					$scope.totalItems = res.data.totalRecord;
					
					

                }else{
                    alert(res.errmsg);
                }
            });

    };
	$scope.pageChanged();

			$scope.b= '0';
			$scope.c = '';
			$scope.show = function(index){				
				if($scope.b==0){
					$scope.b='1',
					$scope.c=index
				}else if($scope.b==1){
					if($scope.c!=index){
						$scope.c=index
					}else{
						$scope.b='0',
						$scope.c=index
					}	
				}		
			};
			


			$scope.search=function(){
			var dic = {
				pageNo:$scope.currentPage,
            	pageSize:$scope.itemsPerPage,

			}
				console.log(dic);
				$resource('', {}, {}).save(dic, function(res){
                if(res.errcode === 0 || res.errcode === 10003){
                    // console.log(res);
					$scope.a=res.data.results;
					console.log($scope.a);
                    $scope.totalItems = res.data.totalRecord;
                }else{
                    alert(res.errmsg);
                }
            });
			}



			$scope.arr = [

			]


			$scope.typearr = [
				{name:'酷酷的车',value:'0'},
				{name:'法拉利',value:'1'},
				{name:'保时捷',value:'2'},
			]

			$scope.weightarr = [
				{name:'50t',value:'0'},
				{name:'60t',value:'1'},
				{name:'70t',value:'2'},
			]

			$scope.addtypearr=function(index){
				for(var i = 0;i<$scope.arr.length;i++){
					if($scope.typearr[index].name==$scope.arr[i]){
						alert('不能重复添加');
						return;
					}
				}
				$scope.arr.push($scope.typearr[index].name);
			}
			$scope.addweightarr=function(index){
				for(var i = 0;i<$scope.arr.length;i++){
					if($scope.weightarr[index].name==$scope.arr[i]){
						alert('不能重复添加');
						return;
					}
				}
				$scope.arr.push($scope.weightarr[index].name);
			}
			$scope.remove = function(index){
				$scope.arr.splice(index,1);
			}
};

